package com.jz.netthings.bloodsources.service.impl;

import com.jz.netthings.application.bodyCheck.bean.MyPage;
import com.jz.netthings.bloodsources.bean.XyLink;
import com.jz.netthings.bloodsources.bean.XyLinkNurseUpdateList;
import com.jz.netthings.bloodsources.mapper.XyLinkMapper;
import com.jz.netthings.bloodsources.mapper.XyLinkNurseUpdateListMapper;
import com.jz.netthings.bloodsources.service.XyLinkNurseUpdateListService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jz.netthings.exception.AdscmSystemException;
import com.jz.netthings.security.utils.Token;
import com.jz.netthings.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 血源链接护士修改配置清单记录表 服务实现类
 * </p>
 *
 * @author 张凡
 * @since 2019-08-03
 */
@Service
public class XyLinkNurseUpdateListServiceImpl extends ServiceImpl<XyLinkNurseUpdateListMapper, XyLinkNurseUpdateList> implements XyLinkNurseUpdateListService {
    @Autowired
    private XyLinkNurseUpdateListMapper xyLinkNurseUpdateListMapper;
    @Override
    public MyPage<XyLinkNurseUpdateList> queryByCondition(String linkId, String currentPage, String pageSize) throws AdscmSystemException {
        //进行分页数据判定
        MyPage<XyLinkNurseUpdateList> myPage=new MyPage<XyLinkNurseUpdateList>();
        myPage.setCurrentPageIndex(Integer.parseInt(currentPage));
        myPage.setPageSize(Integer.parseInt(pageSize));
        //对当前页参数currentPage 进行重新定义，为节省JVM资源开销，直接将计算后的开始页赋值给参数变量currentPage = beginIndex
        currentPage = myPage.getBeginIndex()+"";
        Integer count = xyLinkNurseUpdateListMapper.queryByCount(linkId);
        List<XyLinkNurseUpdateList> list  = xyLinkNurseUpdateListMapper.queryByCondition(linkId,Integer.parseInt(currentPage),Integer.parseInt(pageSize));
        //获取相关数据
        myPage.setItems(list);
        myPage.setTotal(count);
        return myPage;
    }
    @Override
    public Boolean insertXyLinkNurseUpdateListInfo(XyLinkNurseUpdateList xyLinkNurseUpdateList, Token token) throws AdscmSystemException {
        boolean insert = false;
        synchronized (this) {
            insert = super.insert(xyLinkNurseUpdateList);
            return insert;
        }
    }
}
